<template>
  <div>
    <van-nav-bar
      :z-index="999"
      :fixed="true"
      left-arrow
      @click-left="onClickLeft"
      :placeholder="true"
      title="订单详情"
    ></van-nav-bar>
    <!-- 订单详情 -->
    <van-cell-group>
      <van-cell title="订单编号" :value="ordercode" />
      <van-cell title="订单状态" :value="condition" />
      <van-cell title="订单生成时间" :value="ddsctime" />
      <van-cell title="订单完成时间" :value="wctime" />
      <van-cell title="姓名" :value="name" />
      <van-cell title="教练" :value="drillname" />
      <van-cell title="科目" :value="km" />
      <van-cell title="车型" :value="cx" />
      <van-cell title="约车时间" :value="yctime" />
    </van-cell-group>

    <!-- 可以查看驾校和教练的评价 -->
    <div v-if="status == '3'" class="evaluate">
      <!-- 订单 -->
      <div class="evaluate-title">
        <!-- <img :src="title.img" /> -->
        <p>{{ title.cnr }}</p>
      </div>

      <div class="e-estimate">驾校评价</div>
      <div class="hierarchy">
        <div>
          <p>驾校设施评分</p>
          <van-rate :readonly="true" v-model="sGrade" />
        </div>
        <div>
          <p>驾校质量</p>
          <van-rate :readonly="true" v-model="Sgrade" />
        </div>

        <!-- 输入内容 -->
      </div>
      <van-field
        style="padding:0;"
        v-model="Smessage"
        rows="2"
        autosize
        label="评价"
        type="textarea"
        show-word-limit
        :disabled="true"
      />

      <div class="e-estimate">教练评价</div>

      <div class="hierarchy">
        <div>
          <p>教练服务质量</p>
          <van-rate :readonly="true" v-model="value1" />
        </div>
        <div>
          <p>教练技术</p>
          <van-rate :readonly="true" v-model="value2" />
        </div>

        <!-- 输入内容 -->
      </div>
      <van-field
        style="padding:0;"
        v-model="message"
        rows="2"
        autosize
        label="评价"
        type="textarea"
        show-word-limit
        :disabled="true"
      />
    </div>
  </div>
</template>

<script>
import { orderInformation, QueryCondition } from "../../../assets/js/api/user";
export default {
  name: "OrdersDetails",
  data() {
    return {
      Details: [],
      ordercode: "", // 订单编号
      condition: "", // 订单状态
      ddsctime: "", // 订单生成时间
      wctime: "", // 订单完成时间
      name: "", // 姓名
      drillname: "", // 教练
      km: "", // 科目
      cx: "", // 车型
      yctime: "", // 约车时间
      value1: 0, // 教练服务质量
      value2: 0, // 教练技术
      Smessage: "", // 评价内容
      baseURL: "",
      title: "",
      sGrade: 0, // 设施评分
      Sgrade: 0, // 驾校质量评分
      message: "", // 驾校评价内容
      status: "" // 判断评价内容是否显示
    };
  },
  mounted() {
    QueryCondition(this.$route.params.id).then(res => {
      this.sGrade = res.data.jxpj.sspf;
      this.Sgrade = res.data.jxpj.ffzl;
      this.Smessage = res.data.jxpj.remark;
      this.value1 = res.data.jlPj.fwzl;
      this.value2 = res.data.jlPj.jljs;
      this.message = res.data.jlPj.remarks;
      this.status = res.data.list[0].ddstatus;
      // console.log(this.status);
      // console.log(res);
    });

    orderInformation(this.$route.params.id).then(res => {
      console.log(res);
      this.Details = res.data;
      this.ordercode = this.Details[0].ordercode;
      this.ddsctime = this.Details[0].ddsctime;
      this.wctime = this.Details[0].wctime;
      this.name = this.Details[0].name;
      this.drillname = this.Details[0].drillname;
      // this.km = this.Details[0].km;
      switch (this.Details[0].km) {
        case "1":
          this.km = "科目一";
          break;
        case "2":
          this.km = "科目二";
          break;
        case "3":
          this.km = "科目三";
          break;
        case "4":
          this.km = "科目四";
          break;
      }
      this.cx = this.Details[0].cx;
      this.yctime = this.Details[0].yctime;
      if (this.Details[0].jxsh === "1") {
        this.condition = "待审核";
      }
      if (this.Details[0].jxsh === "6") {
        this.condition = "审核失败";
      }
      if (this.Details[0].jxsh === "5") {
        this.condition = "审核成功";
      }
      if (this.Details[0].jxsh === "7") {
        this.condition = "旷课";
      }
      if (this.Details[0].jxsh === "9") {
        this.condition = "旷课退费";
      }
    });
  },
  methods: {
    onClickLeft() {
      this.$router.go(-1);
    }
  },
  created() {
    let dsBridge = require("dsbridge");
    dsBridge.call("goBack", "", function() {
      history.go(-1);
    });
  }
};
</script>

<style></style>
